#!/bin/bash
#
## 初始化变量
#      # 00000000000000 600380.log
#prefix="000000000000006"
#start=1
#end=1000
#
## 生成1000条插入语句
#for ((i=start; i<=end; i++))
#do
#    TERMINAL_SN=$(printf "%s%05d" "$prefix" "$i")
#    REGION_ID=2057
#    VEH_CODE=$(printf "%04d" $((RANDOM % 10000)))
#    VEH_PLATE_NUM=$(printf "%04d" $((RANDOM % 10000)))
#    OWN_UNIT_ID=5671
#    USE_UNIT_ID=13535
#
#    # 打印插入语句
#    echo "INSERT INTO VDAM.TERMINAL_BUSINESS_INFO (TERMINAL_SN, REGION_ID, VEH_CODE, VEH_PLATE_NUM, OWN_UNIT_ID, USE_UNIT_ID)"
#    echo "VALUES('$TERMINAL_SN', $REGION_ID, '$VEH_CODE', '$VEH_PLATE_NUM', $OWN_UNIT_ID, $USE_UNIT_ID);"
#done
#
#echo "COMMIT"



# 初始化变量
prefix="000000000000006"
start=1
end=1000
output="genDevInsert.sql"
echo "" > ${output}
# 生成1000条插入语句
for ((i=start; i<=end; i++))
do
    TERMINAL_SN=$(printf "%s%05d" "$prefix" "$i")
    REGION_ID=2057
    VEH_CODE=$(printf "%04d" $((RANDOM % 10000)))
    VEH_PLATE_NUM=$(printf "%04d" $((RANDOM % 10000)))
    OWN_UNIT_ID=5671
    USE_UNIT_ID=13535
    CREATE_TIME=$(date "+%Y-%m-%d %H:%M:%S.%3N")
    UPDATE_TIME=$(date "+%Y-%m-%d %H:%M:%S.%3N")
    echo "$start --> $i --> $end"

    # 打印插入语句
    echo "INSERT INTO VDAM.TERMINAL_BUSINESS_INFO (TERMINAL_SN, REGION_ID, VEH_CODE, VEH_PLATE_NUM, OWN_UNIT_ID, USE_UNIT_ID, CREATE_TIME, UPDATE_TIME)" >> ${output}
    echo "VALUES('$TERMINAL_SN', $REGION_ID, '$VEH_CODE', '$VEH_PLATE_NUM', $OWN_UNIT_ID, $USE_UNIT_ID, '$CREATE_TIME', '$UPDATE_TIME');"  >> ${output}
done

echo "COMMIT;"  >> ${output}
